package com.wash.shoes.common.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 工厂的服务类型枚举
 */
@AllArgsConstructor
@Getter
public enum FactoryServiceTypeEnum {
    CARPET("CARPET", "地毯"), REPAIR("REPAIR", "维修"), LUXURY_CARE("LUXURY_CARE", "奢养"), WASH_SHOES("WASH_SHOES", "洗鞋"),
    WASH_CLOTHES("WASH_CLOTHES", "洗衣");

    @EnumValue
    private String code;
    @JsonValue
    private String name;

    @JsonCreator
    public static FactoryServiceTypeEnum getEnumByCode(String code) {
        for (FactoryServiceTypeEnum value : values()) {
            if (value.code.equals(code)) {
                return value;
            }
        }
        return null;
    }

    /**
     * 获取工厂类型
     *
     * @return
     */
    public static List<Map> getAllFactoryType() {
        List<Map> list = new ArrayList<>();
        for (FactoryServiceTypeEnum value : values()) {
            Map<String, String> map = new HashMap<>();
            map.put("code", value.code);
            map.put("name", value.name);
            list.add(map);
        }
        return list;
    }

    public Map<String, String> toMap() {
        Map<String, String> map = new HashMap<>();
        map.put("code", code);
        map.put("name", name);
        return map;
    }
}
